package JavaSe;

import javax.swing.plaf.synth.SynthOptionPaneUI;
import java.io.*;
import java.sql.SQLOutput;
import java.util.HashSet;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}9:27
 */
public class People implements Serializable {
    private int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public static void main(String[] args) {

        People p = new People();
        p.setAge(10);
        ObjectOutputStream oos = null;
        ObjectInputStream ois = null;
        try {
            FileOutputStream fos = new FileOutputStream("people.out");
            oos = new ObjectOutputStream(fos);
            oos.writeObject(p);
            oos.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        People p1;
        try {
            FileInputStream fis = new FileInputStream("people.out");
            ois = new ObjectInputStream(fis);
            p1 = (People) ois.readObject();
            System.out.println(p1.getAge());
            ois.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}